﻿using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace ModuleA.ViewModels
{
    class ViewAViewModel:BindableBase,IConfirmNavigationRequest//,INavigationAware
    {
		private string _Msg;

		public string Msg
		{
			get { return _Msg; }
			set { _Msg = value;
				RaisePropertyChanged();
			}
		}

        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="navigationContext"></param>
        /// <param name="continuationCallback"></param>
        /// <exception cref="NotImplementedException"></exception>
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
        {
            bool result = MessageBox.Show("确定切换吗？","温馨提示",MessageBoxButton.YesNoCancel)==MessageBoxResult.Yes;
            continuationCallback(result);
        }

        /// <summary>
        /// 是否宠用上次实例进行导航
        /// </summary>
        /// <param name="navigationContext"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
        }

        /// <summary>
        /// 当导航到该视图时，获取参数
        /// </summary>
        /// <param name="navigationContext"></param>
        /// <exception cref="NotImplementedException"></exception>
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            if(navigationContext.Parameters.ContainsKey("MsgA"))
               Msg = navigationContext.Parameters.GetValue<string>("MsgA");
        }
    }
}
